home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / sound / votrax.c < prev    next >
C/C++ Source or Header  |  2000-04-23  |  2KB  |  84 lines

  1. /**************************************************************************
  2.  
  3.     Votrax SC-01 Emulator
  4.  
  5.      Mike@Dissfulfils.co.uk
  6.  
  7. **************************************************************************
  8.  
  9. sh_votrax_start  - Start emulation, load samples from Votrax subdirectory
  10. sh_votrax_stop   - End emulation, free memory used for samples
  11. votrax_w         - Write data to votrax port
  12. votrax_status    - Return busy status (-1 = busy)
  13.  
  14. If you need to alter the base frequency (i.e. Qbert) then just alter
  15. the variable VotraxBaseFrequency, this is defaulted to 8000
  16.  
  17. **************************************************************************/
  18.  
  19. #include "driver.h"
  20.  
  21. int        VotraxBaseFrequency;        /* Some games (Qbert) change this */
  22. int     VotraxBaseVolume;
  23. int     VotraxChannel;
  24.  
  25. struct  GameSamples *VotraxSamples;
  26.  
  27. /****************************************************************************
  28.  * 64 Phonemes - currently 1 sample per phoneme, will be combined sometime!
  29.  ****************************************************************************/
  30.  
  31. static const char *VotraxTable[65] =
  32. {
  33.  "EH3","EH2","EH1","PA0","DT" ,"A1" ,"A2" ,"ZH",
  34.  "AH2","I3" ,"I2" ,"I1" ,"M"  ,"N"  ,"B"  ,"V",
  35.  "CH" ,"SH" ,"Z"  ,"AW1","NG" ,"AH1","OO1","OO",
  36.  "L"  ,"K"  ,"J"  ,"H"  ,"G"  ,"F"  ,"D"  ,"S",
  37.  "A"  ,"AY" ,"Y1" ,"UH3","AH" ,"P"  ,"O"  ,"I",
  38.  "U"  ,"Y"  ,"T"  ,"R"  ,"E"  ,"W"  ,"AE" ,"AE1",
  39.  "AW2","UH2","UH1","UH" ,"O2" ,"O1" ,"IU" ,"U1",
  40.  "THV","TH" ,"ER" ,"EH" ,"E1" ,"AW" ,"PA1","STOP",
  41.  0
  42. };
  43.  
  44. void sh_votrax_start(int Channel)
  45. {
  46.     VotraxSamples = readsamples(VotraxTable,"votrax");
  47.     VotraxBaseFrequency = 8000;
  48.     VotraxBaseVolume = 230;
  49.     VotraxChannel = Channel;
  50. }
  51.  
  52. void sh_votrax_stop(void)
  53. {
  54.     freesamples(VotraxSamples);
  55. }
  56.  
  57. void votrax_w(int data)
  58. {
  59.     int Phoneme,Intonation;
  60.  
  61.     Phoneme = data & 0x3F;
  62.     Intonation = data >> 6;
  63.  
  64.       logerror("Speech : %s at intonation %d\n",VotraxTable[Phoneme],Intonation);
  65.  
  66.     if(Phoneme==63)
  67.            mixer_stop_sample(VotraxChannel);
  68.  
  69.     if(VotraxSamples->sample[Phoneme])
  70.     {
  71.         mixer_set_volume(VotraxChannel,VotraxBaseVolume+(8*Intonation)*100/255);
  72.         mixer_play_sample(VotraxChannel,VotraxSamples->sample[Phoneme]->data,
  73.                   VotraxSamples->sample[Phoneme]->length,
  74.                   VotraxBaseFrequency+(256*Intonation),
  75.                   0);
  76.     }
  77. }
  78.  
  79. int votrax_status_r(void)
  80. {
  81.     return mixer_is_sample_playing(VotraxChannel);
  82. }
  83.  
  84.